package com.lehoon.tomato.global;

import com.lehoon.tomato.model.common.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
@ResponseBody
@Slf4j
public class GlobalExceptionHandler {

    @ExceptionHandler(value = Exception.class)
    public Result exceptionHandler(Exception e){
        Result result = new Result();
        result.setCode(500);
        result.setError(e.getMessage());
        log.error(e.getMessage(),e);
        return result;
    }
}